import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import { SurveyService } from './survey.service';
import { CreateSurveyDto } from './dto/create-survey.dto';
import { UpdateSurveyDto } from './dto/update-survey.dto';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { Survey } from './entities/survey.entity';
import { SurveyQueryDto } from './dto/query-survey.dto';

@ApiTags('Surveys')
@Controller('survey')
export class SurveyController {
  constructor(private readonly surveyService: SurveyService) {}

  @Post('create')
  @ApiOperation({ summary: 'Create a new survey' })
  async create(@Body() createSurveyDto: CreateSurveyDto): Promise<Survey> {
    return this.surveyService.create(createSurveyDto);
  }

  // @Get()
  // async findAll(@Query() surveyQueryDto: SurveyQueryDto): Promise<PaginationSurvey<Survey>> {
  //   return this.surveyService.findAll(surveyQueryDto);
  // }
  @Post('list')
  @ApiOperation({ summary: 'Get a paginated list of surveys' })
  findAll(@Body() paginationQuery: SurveyQueryDto) {
    return this.surveyService.findAll(paginationQuery);
  }

  @Get(':id')
  @ApiOperation({ summary: 'Get an survey by id' })
  // @Public()
  async findOne(@Param('id') id: string): Promise<Survey> {
    return this.surveyService.findOne(id);
  }

  @Post('update/:id')
  @ApiOperation({ summary: 'Update an survey' })
  async update(@Param('id') id: string, @Body() updateSurveyDto: UpdateSurveyDto): Promise<Survey> {
    return this.surveyService.update(id, updateSurveyDto);
  }

  @Get('delete/:id')
  @ApiOperation({ summary: 'Delete an survey' })
  async remove(@Param('id') id: string): Promise<void> {
    await this.surveyService.remove(id);
  }
  // @Delete('/delete/:id')
  // async delete(@Param('id') id: string): Promise<void> {
  //   await this.surveyService.delete(id);
  // }
}
